
import java.util.Calendar;

/**
 * An edge links a location to another location.
 * It holds the Service which travels along this
 * edge, the start time and the duration it takes
 * this Service to travel along the edge.
 */
public class Edge implements Comparable<Edge>
{
    //The Service which travels along this edge
    private Service service;
    //The start time of this edge
    private Calendar startTime;
    //The duration in minutes of this edge (this duration works as a weight
    //of this edge)
    private int duration;
    //The start and end of location of this Edge
    private Location endLocation;

    /**
     * Constructs an Edge object. An Edge links two Locations together.
     * @param service The service which 'uses' this edge
     * @param startTime The time the Service starts
     * @param duration The duration of this Service
     * @param start The start location of the edge
     * @param end The end location of the edge
     */
    public Edge(Service service, 
                Calendar startTime,
                int duration,
                Location end) {
        this.service = service;
        this.startTime = startTime;
        this.duration = duration;
        this.endLocation = end;
    }

    public int getDuration() {
        return duration;
    }

    public Service getService() {
        return service;
    }

    public Calendar getStartTime() {
        return startTime;
    }

    public Location getEndLocation() {
        return endLocation;
    }

    @Override
    public String toString() {
        return "Edge{" + "service=" + service + "startTime=" 
                + startTime + "duration=" + duration + "endLocation="
                + endLocation + '}';
    }
    
    @Override
    public int compareTo(Edge other)
    {
        return this.getEndLocation().compareTo(other.getEndLocation());
    }
}
